import request from '@/utils/request'
import { BaseResponse } from '../base'
import { ExpressTakeReq, ExpressTake } from './type'

export function pageQuery(params: ExpressTakeReq): Promise<BaseResponse> {
  return request({ url: '/campus/expressTake/page', method: 'get', params })
}

export function pageQueryMe(params: ExpressTakeReq): Promise<BaseResponse> {
  return request({ url: '/campus/expressTake/pageMe', method: 'get', params })
}

export function getExpressTake(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/detail/${id}`, method: 'get' })
}

export function getExpressTakeMe(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/detailMe/${id}`, method: 'get' })
}

export function publish(expressTake: ExpressTake): Promise<BaseResponse> {
  return request({ url: '/campus/expressTake/publish', method: 'post', data: expressTake })
}

export function apply(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/apply/${id}`, method: 'post' })
}

export function delExpress(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/delete/${id}`, method: 'delete' })
}
export function cancelExpress(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/cancel/${id}`, method: 'put' })
}
export function applyRecord(params: any): Promise<BaseResponse> {
  return request({ url: '/campus/expressTake/applyRecord', method: 'get', params })
}

export function accept(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/accept/${id}`, method: 'put' })
}

export function getByOrderNo(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/getByOrderNo/${orderNo}`, method: 'get' })
}

export function pay(orderNo: string, payMethod: string): Promise<BaseResponse> {
  return request({ url: '/campus/expressTake/pay', method: 'put', params: { orderNo, payMethod } })
}

export function getTakeByOrderNo(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/getTakeByOrderNo/${orderNo}`, method: 'get' })
}

export function myApplyExpress(params: any): Promise<BaseResponse> {
  return request({ url: '/campus/expressTake/myApplyExpress', method: 'get', params })
}

export function showTakeInfo(takeId: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/showTakeInfo/${takeId}`, method: 'get' })
}

export function confirmSend(takeId: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/confirmSend/${takeId}`, method: 'put' })
}

export function confirmReceive(takeId: number): Promise<BaseResponse> {
  return request({ url: `/campus/expressTake/confirmReceive/${takeId}`, method: 'put' })
}